/*
 * 文件名：AlipayController.java
 * 版权：
 * 描述：TODO
 * 修改人：zuo liubo
 * 修改时间：2013-3-13 下午4:33:14
 */
package com.scpii.api.controller.ec;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.scpii.api.service.alipay.HandleAlipayService;

/**
 * @description 处理支付宝 回调和通知
 * @author zuo liubo
 * @date 2013-3-13
 */
@Controller
@RequestMapping("/ec/alipay")
public class AlipayController {
	
	@Resource
	private HandleAlipayService handleAlipayService;
	
	@RequestMapping(value = "/callback", method = RequestMethod.GET)
	@ResponseBody
	public Object callbackFromAlipay(HttpServletRequest request) throws Exception {
		handleAlipayService.callbackFromAlipay(request);
		return null;
	}
	
	@RequestMapping(value = "/notify", method = RequestMethod.POST)
	@ResponseBody
	public ResponseEntity<String>  notifyFromAlipay(HttpServletRequest request) throws Exception {
		boolean result = handleAlipayService.notifyFromAlipay(request);
		String msg = "fail";
		if(result){
			msg = "success";
		}
		return new ResponseEntity<String>(msg, HttpStatus.OK);
	}

}
